﻿using AllDemo.TcpCommunication;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AllDemo
{
    public partial class TCP服务器创建 : Form
    {
        public TCP服务器创建()
        {
            InitializeComponent();
            beginListent();
        }
        ZTcpServer zserver = new ZTcpServer();

        private void beginListent()
        {
            zserver.createConnection("192.168.43.210", 9000);
            zserver.GetClientMsg += getClientMsg;

        }


        public void getClientMsg(string ip ,string msg)
        {
            Console.WriteLine("收到客户"+ip+"的端消息："+msg);
    
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sendStr = txt_send.Text;
            byte []byteArray = System.Text.Encoding.UTF8.GetBytes(sendStr);
            zserver.SendMsgToClient("192.168.43.37", byteArray);
        }
    }
}
